// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2005-1-13

#ifndef __TRANS_TCP_H_SERVER_SVR_MAIN__
#define __TRANS_TCP_H_SERVER_SVR_MAIN__

#pragma once

#include <common/svr_base/net_accept.h>

namespace JoyServer
{

class CJoyMainRoom;
class CJoyMainUser;
class CJoyTransTCPSocket;

class CJoyTransTCP : public CJoyAcceptorEx
{
public:
    typedef CMap<CJoyTransTCPSocket*, CJoyTransTCPSocket*, CJoyMainUser*, CJoyMainUser*> CSockMap;

    CJoyMainRoom*   m_room;
    CSockMap    m_sockets;
    DWORD       m_lastCheck;
    virtual bool OnAccept(SOCKET s, const sockaddr_in& addr);
public:
    CJoyTransTCP();
    virtual ~CJoyTransTCP();

    bool Create(CJoyMainRoom* pRoom);
    void Destroy();

    void RemoveSocket(CJoyTransTCPSocket* pSocket);
};

} // namespace JoyServer

#endif  // __TRANS_TCP_H_SERVER_SVR_MAIN__